Skip to content

feat: claude citation support with BedrockModel #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

theagenticguy
Copy link
Collaborator

@theagenticguy theagenticguy commented Aug 7, 2025

Description

Adds support for citations when using Anthropic Claude Sonnet 3.5v2 and above

Related Issues

#570

Documentation PR

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@theagenticguy theagenticguy marked this pull request as ready for review August 8, 2025 21:49
@theagenticguy theagenticguy changed the title Claude citations feat: claude citation support with BedrockModel Aug 8, 2025
@zastrowm zastrowm added the area-provider Related to model providers label Aug 11, 2025
@@ -24,10 +24,11 @@
from mcp.types import ImageContent as MCPImageContent
from mcp.types import TextContent as MCPTextContent

from strands.types.tools import ToolResultContent, ToolResultStatus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why relative to absolute import?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mypy was complaining without it

if "citationsContent" not in state:
state["citationsContent"] = []

state["citationsContent"].append(delta_content["citation"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just appending the response to a list, I can see that the CitationSourceContentDelta event mentions that it contains "incremental updates to the source content text during streaming responses". Does this mean we are concatenating the strings of the CitationSourceContentDelta events, or just appending the events to an array?

@@ -206,6 +214,18 @@ def handle_content_block_stop(state: dict[str, Any]) -> dict[str, Any]:
)
state["reasoningText"] = ""

# Handle citations_content independently - not as elif since we can have both text and citations
if citations_content:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be made into an elif?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-provider Related to model providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants